<template>
  <div>
    <el-table
      :data="tableData"
      border
      style="width: 100%"
      height="1100">
      <el-table-column
        prop="account"
        label="账号">
      </el-table-column>
      <el-table-column
        prop="userName"
        label="昵称">
      </el-table-column>
      <el-table-column
        prop="date"
        label="时间">
      </el-table-column>
      <el-table-column
        prop="address"
        label="IP">
      </el-table-column>
      <el-table-column
      prop="jurisdiction"
      label="权限">
    </el-table-column>
      <el-table-column
        prop="okAdminName"
        label="审核员">
      </el-table-column>
      <el-table-column
        prop="okTime"
        label="通过时间">
      </el-table-column>
      <el-table-column
        prop="channelId"
        label="渠道">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="渠道设置"
        width="125">
        <template slot-scope="scope" v-if="!scope.row.ok">
          <el-input style="width: 100%"
                    placeholder="请输渠道"
                    v-model="inputDesc" />
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="权限"
        width="125">
        <template slot-scope="scope" v-if="!scope.row.ok">
          <el-select  style="width: 100%" v-model="value" placeholder="权限选择" >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope" v-if="!scope.row.ok">
          <el-button @click="handleClick(scope.row)" type="primary" icon="el-icon-edit" circle size="mini"></el-button>
          <el-button @click="closeClick(scope.row)" type="danger" icon="el-icon-delete" circle size="mini"></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <el-pagination
      style="margin-top: 20px"
      v-show="this.tableData.length > 20"
      background
      layout="prev, pager, next"
      :total="1000">
    </el-pagination>

  </div>

</template>

<script>
  import axios from 'axios'
  export default {
   created(){
    this.requestInfo()
   },
    data() {
      return {
        inputDesc:1,
        tableData: [],
        options: [{
          value: '1',
          label: '普通管理'
        }, {
          value: '2',
          label: '超级管理'
        }],
        value: '1',
      }
    },
    methods: {
      handleClick(row) {
        axios.get("newadminok",{
          params:{
            account:row.account,
            jurisdiction:this.value,
            channelId:this.inputDesc
          }
        }).then(resp => {
            if(resp.data.result){
              this.$alert(resp.data.msg, "审核", {
                confirmButtonText: '确定',
                callback: action => {
                  this.requestInfo();
                }
              })
            }else {
              alert(resp.data.error)
            }
        }).catch(err => {
          alert(err)
        })
      },
      closeClick(row) {
        axios.get("newadminno",{
          params:{
            account:row.account,
          }
        }).then(resp => {
          if(resp.data.result){
            this.$alert(resp.data.msg, "审核", {
              confirmButtonText: '确定',
              callback: action => {
                this.requestInfo();
              }
            })
          }else {
            alert(resp.data.error)
          }
        }).catch(err => {
          alert(err)
        })
      },
      requestInfo(){
        axios.get("newadmin").then(resp => {
          if(resp.data.result){
            //成功
            this.tableData = resp.data.msg;
          }
        }).catch(err => {})
      },
    },

  }
</script>

<style scoped>

</style>
